﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace FeedReaderApp.Common
{
    public class ImageUrlConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var url = (string)value;
            url = string.IsNullOrEmpty(url) ? "ms-appx:/Assets/placeholder2.png" : url;

            if (url.Contains("feedads.g.doubleclick.net"))
                url = "ms-appx:/Assets/placeholder2.png";

            if (url.EndsWith("/"))
                url = "ms-appx:/Assets/placeholder2.png";

            if (url.Contains("aggbug.aspx?PostID="))
                url = "ms-appx:/Assets/placeholder2.png";

            return url;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
